package com.liao.bean;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component("bean1")
public class User {
    @Value("1")
    private Integer id;
    @Value("张三")
    private String username;

    @Autowired
    private Bean2 bean2;

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", bean2=" + bean2 +
                ", bean3=" + bean3 +
                '}';
    }

//    @Autowired
//    @Qualifier("bean3Impl1")
//    private Bean3 bean3;

    @Resource(name = "bean3Impl2")
    private Bean3 bean3;

    public User() {
    }

    public User(Integer id, String username) {
        this.id = id;
        this.username = username;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

}
